package org.example.api.psn;

import com.alibaba.csp.sentinel.annotation.SentinelResource;
import org.example.system.common.bean.MyFeignBlockHandlerService;
import org.example.system.common.bean.MyFeignFallbackService;
import org.example.system.common.constant.ServiceConstant;
import org.example.system.common.dto.UserAuthDto;
import org.example.system.common.dto.psn.UserInfoDto;
import org.example.system.common.utils.ResponseUtil;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

/**
 *
 */
@FeignClient(name = ServiceConstant.KEY_PSN)
public interface IPersonServiceFeignClient{
    /**
     * 通过用户id获取去重名称集合
     * @return
     */
    @SentinelResource(value = "/v1/person/names",
            fallbackClass= MyFeignFallbackService.class,fallback = "fallback",
            blockHandlerClass = MyFeignBlockHandlerService.class,blockHandler="blockHandler")
    @GetMapping("/v1/person/names")
    ResponseUtil<String> queryNamesById(
            @RequestParam("psnIds") String psnIds);
    /**
     * 通过用户id获取用户信息
     * @return
     */
    @SentinelResource(value = "/v1/person/userInfo/psnId",
            fallbackClass= MyFeignFallbackService.class,fallback = "fallback",
            blockHandlerClass = MyFeignBlockHandlerService.class,blockHandler="blockHandler")
    @GetMapping("/v1/person/userInfo/{psnId}")
    ResponseUtil<UserInfoDto> queryPersonById(
            @PathVariable("psnId") Long psnId);
    /**
     * 通过token获取授权信息
     * @return
     */
    @SentinelResource(value = "/v1/person/authInfo",
            fallbackClass= MyFeignFallbackService.class,fallback = "fallback",
            blockHandlerClass = MyFeignBlockHandlerService.class,blockHandler="blockHandler")
    @GetMapping("/v1/person/authInfo")
    ResponseUtil<UserAuthDto> queryAuthInfoByToken();
}
